home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / arts / buffer.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-09-10  |  2.8 KB  |  105 lines

  1.     /*
  2.  
  3.     Copyright (C) 2000 Stefan Westerfeld
  4.                        stefan@space.twc.de
  5.  
  6.     This library is free software; you can redistribute it and/or
  7.     modify it under the terms of the GNU Library General Public
  8.     License as published by the Free Software Foundation; either
  9.     version 2 of the License, or (at your option) any later version.
  10.   
  11.     This library is distributed in the hope that it will be useful,
  12.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.     Library General Public License for more details.
  15.    
  16.     You should have received a copy of the GNU Library General Public License
  17.     along with this library; see the file COPYING.LIB.  If not, write to
  18.     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19.     Boston, MA 02111-1307, USA.
  20.  
  21.     */
  22.  
  23. #ifndef BUFFER_H
  24. #define BUFFER_H
  25.  
  26. #include <string>
  27. #include <vector>
  28. #include "arts_export.h"
  29. /*
  30.  * BC - Status (2002-03-08): Buffer.
  31.  *
  32.  * Has to be kept binary compatible. As buffer is speed relevant, currently
  33.  * there are no private d ptrs, and the idea is to keep this as possible.
  34.  *
  35.  * If not, put additional stuff in the d ptr, but keep as much data as
  36.  * possible in the main items.
  37.  */
  38.  
  39. namespace Arts {
  40.  
  41. #ifndef MCOPBYTE_DEFINED
  42. #define MCOPBYTE_DEFINED
  43. typedef unsigned char mcopbyte;
  44. #endif
  45.  
  46. class BufferPrivate;
  47.  
  48. class ARTS_EXPORT Buffer {
  49. private:
  50.     long rpos;
  51.     bool _readError;
  52.     std::vector<unsigned char> contents;
  53.  
  54.     BufferPrivate *d;    // unused
  55.     unsigned char fromHexNibble(char c);
  56.  
  57. public:
  58.     Buffer();
  59.     ~Buffer();
  60.  
  61.     bool readError();
  62.     void writeBool(bool b);
  63.     void writeBoolSeq(const std::vector<bool>& seq);
  64.     void writeByte(mcopbyte b);
  65.     void writeByteSeq(const std::vector<mcopbyte>& seq);
  66.     void writeLong(long l);
  67.     void writeLongSeq(const std::vector<long>& seq);
  68.     void writeFloat(float f);
  69.     void writeFloatSeq(const std::vector<float>& seq);
  70.     void writeString(const std::string& s);
  71.     void writeStringSeq(const std::vector<std::string>& seq);
  72.  
  73.     long size();
  74.     long remaining();
  75.     void *read(long l);
  76.     void read(std::vector<mcopbyte>& raw, long l);
  77.     void *peek(long l);
  78.     void skip(long l);
  79.     void rewind();
  80.  
  81.     void write(void *data, long l);
  82.     void write(const std::vector<mcopbyte>& raw);
  83.  
  84.     bool readBool();
  85.     void readBoolSeq(std::vector<bool>& result);
  86.     mcopbyte readByte();
  87.     void readByteSeq(std::vector<mcopbyte>& result);
  88.     long readLong();
  89.     void readLongSeq(std::vector<long>& result);
  90.     float readFloat();
  91.     void readFloatSeq(std::vector<float>& result);
  92.     void readString(std::string& result);
  93.     void readStringSeq(std::vector<std::string>& result);
  94.  
  95.     void patchLength();
  96.     void patchLong(long position, long value);
  97.  
  98.     std::string toString(const std::string& name);
  99.     bool fromString(const std::string& data, const std::string& name);
  100. };
  101.  
  102. }
  103.  
  104. #endif
  105.